package orthoplanner.com.google.code.ui;

import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;

import javax.swing.JCheckBox;
import javax.swing.JPanel;
import javax.swing.border.TitledBorder;

import orthoplanner.com.google.code.eventhandlers.ImageFreezeHandler;


public class ImageControlPanel extends JPanel {
	private static final long serialVersionUID = 3457045078397447314L;
	private RotationPanel rotPanel;
	private ScalePanel scalePanel;
	private JCheckBox freeze;
	private ContrastPanel contrastPanel;

	public ImageControlPanel(ImageViewer imgViewer) {
		setFont( new Font("SansSerif", Font.BOLD, 12));
		rotPanel = new RotationPanel(imgViewer);
		scalePanel = new ScalePanel(imgViewer);
		contrastPanel=new ContrastPanel(imgViewer);
		freeze = new JCheckBox("Freeze X-Ray");
		freeze.setFont( new Font("SansSerif", Font.BOLD, 12));
		setLayout(new GridBagLayout());
		GridBagConstraints gbc = new GridBagConstraints();
		gbc.weightx = 1.0;
		gbc.weighty = 1.0;
		gbc.fill = GridBagConstraints.HORIZONTAL;
		gbc.anchor = GridBagConstraints.PAGE_START;
		add(rotPanel, gbc);
		gbc.gridy = 1;
		add(scalePanel, gbc);
		gbc.gridy =2;
		add(contrastPanel,gbc);
		gbc.gridy = 3;
		add(freeze, gbc);
		freeze.addMouseListener(new ImageFreezeHandler(scalePanel.getSlScale(),
				rotPanel.getSlRotation(), scalePanel.getbScaleReset(), rotPanel
						.getbRotationReset()));
		freeze.setSelected(true);
		scalePanel.getSlScale().setEnabled(false);
		rotPanel.getSlRotation().setEnabled(false);
		scalePanel.getbScaleReset().setEnabled(false);
		rotPanel.getbRotationReset().setEnabled(false);
		setBorder(new TitledBorder("Image Controls"));
	}

}
